import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';

/// 底部弹出，内容自定义（不一定是选择）
class CustomBottom extends StatelessWidget {
  const CustomBottom({required this.title, required this.child, super.key});

  /// 内容
  final Widget child;

  /// 标题
  final String title;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          gradient: const LinearGradient(
            colors: [
              Color(0xFFE7EAFF),
              Colors.white,
              Colors.white,
            ],
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
          ),
          borderRadius: BorderRadius.circular(17.w)),
      padding: EdgeInsets.symmetric(vertical: 7.w, horizontal: 13.w),
      height: 300.w,
      child: SingleChildScrollView(
        child: Column(
          children: [
            Padding(
              padding: EdgeInsets.all(13.w),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    title,
                    style: TextStyle(
                      fontSize: 18.w,
                      color: const Color(0xFF262F38),
                    ),
                  ),
                  Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(17.w),
                      color: Colors.white,
                    ),
                    height: 24.w,
                    width: 24.w,
                    child: Icon(
                      Icons.close,
                      size: 18.w,
                      color: const Color(0xFF262F38),
                    ),
                  ).clickOnce(Get.back),
                ],
              ),
            ),
            SafeArea(child: child),
          ],
        ),
      ),
    );
  }

  static Future<T?> show<T>({required Widget child, required String title}) async {
    return await Get.bottomSheet<T>(
      CustomBottom(title: title, child: child),
    );
  }
}
